//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.goldplusgold.tradedelay.app.home.live.widget;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.SurfaceHolder.Callback;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import com.aliyun.vodplayer.media.AliyunDataSource;
import com.aliyun.vodplayer.media.AliyunLocalSource;
import com.aliyun.vodplayer.media.AliyunMediaInfo;
import com.aliyun.vodplayer.media.AliyunPlayAuth;
import com.aliyun.vodplayer.media.AliyunVodPlayer;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnBufferingUpdateListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnChangeQualityListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnCompletionListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnErrorListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnInfoListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnLoadingListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.OnPreparedListener;
import com.aliyun.vodplayer.media.IAliyunVodPlayer.PlayerState;
import com.aliyun.vodplayer.utils.VcPlayerLog;
import com.aliyun.vodplayerview.dialog.GestureDialogManager;
import com.aliyun.vodplayerview.dialog.TipsView;
import com.aliyun.vodplayerview.dialog.TipsView.OnTipClickListener;
import com.aliyun.vodplayerview.utils.NetWatchdog;
import com.aliyun.vodplayerview.utils.NetWatchdog.NetChangeListener;
import com.aliyun.vodplayerview.utils.urlimageviewhelper.UrlImageViewHelper;
import com.aliyun.vodplayerview.view.control.ControlView;
import com.aliyun.vodplayerview.view.control.ControlView.OnPlayStateClickListener;
import com.aliyun.vodplayerview.view.control.ControlView.OnQualityClickListener;
import com.aliyun.vodplayerview.view.control.ControlView.OnSeekListener;
import com.aliyun.vodplayerview.view.control.ControlView.PlayState;
import com.aliyun.vodplayerview.view.gesture.GestureView;
import com.aliyun.vodplayerview.view.gesture.GestureView.GestureListener;
import com.aliyun.vodplayerview.view.interfaces.ViewAction.HideType;
import com.aliyun.vodplayerview.widget.AliyunScreenMode;
import java.util.concurrent.ExecutorService;

public class AliyunVodPlayerView extends RelativeLayout {
    private static final String TAG = AliyunVodPlayerView.class.getSimpleName();
    private SurfaceView mSurfaceView;
    private GestureView mGestureView;
    private ControlView mControlView;
    private ImageView mCoverView;
    private AliyunVodPlayer mAliyunVodPlayer;
    private GestureDialogManager mGestureDialogManager;
    private NetWatchdog mNetWatchdog;
    public TipsView mTipsView;
    private AliyunVodPlayerView.ReplaySourceCallback replaySourceCallback = null;
    private AliyunMediaInfo mAliyunMediaInfo;
    private int mCurrentBufferPercentage = 0;
    private OnInfoListener mOutInfoListener = null;
    private OnErrorListener mOutErrorListener = null;
    private OnPreparedListener mOutPreparedListener = null;
    private OnCompletionListener mOutCompletionListener = null;
    private OnChangeQualityListener mOutChangeQualityListener = null;
    private AliyunDataSource mAliyunDataSource;
    private AliyunPlayAuth mAliyunPlayAuth;
    private AliyunLocalSource mAliyunLocalSource;
    private Handler progressUpdateTimer = new Handler(Looper.getMainLooper()) {
        public void handleMessage(Message msg) {
            AliyunVodPlayerView.this.mControlView.updatePosition((int)AliyunVodPlayerView.this.mAliyunVodPlayer.getCurrentPosition());
            AliyunVodPlayerView.this.startProgressUpdateTimer();
        }
    };
    private PlayerState mPlayerState;

    public AliyunVodPlayerView(Context context) {
        super(context);
        this.initVideoView();
    }

    public AliyunVodPlayerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.initVideoView();
    }

    public AliyunVodPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.initVideoView();
    }

    private void initVideoView() {
        this.initSurfaceView();
        this.initAliVcPlayer();
        this.initCoverView();
        this.initGestureView();
        this.initControlView();
        this.initTipsView();
        this.initNetWatchdog();
        this.initGestureDialogManager();
        this.hideViews();
    }

    private void hideViews() {
        this.mGestureView.hide(HideType.Normal);
        this.mControlView.hide(HideType.Normal);
    }

    //判断网络连接
    private void initNetWatchdog() {
        Context context = this.getContext();
        if(context instanceof Activity) {
            this.mNetWatchdog = new NetWatchdog((Activity)context);
            this.mNetWatchdog.setNetChangeListener(new NetChangeListener() {
                public void onWifiTo4G() {
                    if(AliyunVodPlayerView.this.mAliyunVodPlayer.isPlaying()) {
                        AliyunVodPlayerView.this.mAliyunVodPlayer.pause();
                        AliyunVodPlayerView.this.mGestureView.hide(HideType.Normal);
                        AliyunVodPlayerView.this.mControlView.hide(HideType.Normal);
                    }

                    if(AliyunVodPlayerView.this.mTipsView != null) {
                        AliyunVodPlayerView.this.mTipsView.showNetChangeDialog();
                    }

                }

                public void on4GToWifi() {
                }

                public void onNetDisconnected() {
                }
            });
        }

    }

    private void initGestureDialogManager() {
        Context context = this.getContext();
        if(context instanceof Activity) {
            this.mGestureDialogManager = new GestureDialogManager((Activity)context);
        }

    }

    //提示框
    private void initTipsView() {
        this.mTipsView = new TipsView(this.getContext());
        this.mTipsView.setOnTipClickListener(new OnTipClickListener() {
            public void onContinuePlay() {
                if(AliyunVodPlayerView.this.mAliyunVodPlayer.isPlaying()) {
                    AliyunVodPlayerView.this.mAliyunVodPlayer.start();
                    AliyunVodPlayerView.this.mGestureView.show();
                    AliyunVodPlayerView.this.mControlView.show();
                }

                AliyunVodPlayerView.this.mTipsView.hideAll();
            }

            public void onStopPlay() {
                AliyunVodPlayerView.this.mTipsView.hideAll();
                AliyunVodPlayer aliyunVodPlayer = AliyunVodPlayerView.this.mAliyunVodPlayer;
                aliyunVodPlayer.stop();
                aliyunVodPlayer.release();
                Context context = AliyunVodPlayerView.this.getContext();
                if(context instanceof Activity) {
                    ((Activity)context).finish();
                }

            }

            public void onRetryPlay() {
                AliyunVodPlayerView.this.rePlay();
            }

            public void onReplay() {
                AliyunVodPlayerView.this.rePlay();
            }
        });
        this.addSubView(this.mTipsView);
    }

    //重播
    public void rePlay() {
        AliyunVodPlayer aliyunVodPlayer = this.mAliyunVodPlayer;
        if(aliyunVodPlayer != null) {
            aliyunVodPlayer.stop();
            aliyunVodPlayer.release();
        }

        if(this.mSurfaceView != null) {
            this.mSurfaceView.setVisibility(View.GONE);
            this.mSurfaceView.setVisibility(View.VISIBLE);
        }

        this.mTipsView.hideAll();
        this.initAliVcPlayer();
        this.hideViews();
        this.mControlView.reset();
        this.mGestureView.reset();
        if(this.replaySourceCallback != null) {
            this.replaySourceCallback.setReplaySource();
        }

    }

    public void setReplaySourceCallback(AliyunVodPlayerView.ReplaySourceCallback callback) {
        this.replaySourceCallback = callback;
    }

    private void initCoverView() {
        this.mCoverView = new ImageView(this.getContext());
        this.addSubView(this.mCoverView);
    }

    private void initControlView() {
        this.mControlView = new ControlView(this.getContext());
        this.addSubView(this.mControlView);
        this.mControlView.setOnPlayStateClickListener(new OnPlayStateClickListener() {
            public void onPlayStateClick() {
                AliyunVodPlayerView.this.switchPlayerState();
            }
        });
        this.mControlView.setOnSeekListener(new OnSeekListener() {
            public void onSeek(int position) {
                AliyunVodPlayerView.this.mAliyunVodPlayer.seekTo(position);
            }
        });
        this.mControlView.setOnQualityClickListener(new OnQualityClickListener() {
            public void onQualityClick(String quality) {
                AliyunVodPlayerView.this.mAliyunVodPlayer.changeQuality(quality);
                AliyunVodPlayerView.this.mControlView.updatePlayState(PlayState.Playing);
            }
        });
    }

    private void switchPlayerState() {
        PlayerState playerState = this.mAliyunVodPlayer.getPlayerState();
        if(playerState == PlayerState.Started) {
            this.mAliyunVodPlayer.pause();
            this.mControlView.updatePlayState(PlayState.NotPlaying);
        } else if(playerState == PlayerState.Paused || playerState == PlayerState.Prepared) {
            this.mCoverView.setVisibility(View.GONE);
            this.mAliyunVodPlayer.start();
            this.mControlView.updatePlayState(PlayState.Playing);
        }

    }

    //手势判断
    private void initGestureView() {
        this.mGestureView = new GestureView(this.getContext());
        this.addSubView(this.mGestureView);
        this.mGestureView.setOnGestureListener(new GestureListener() {
            public void onHorizontalDistance(float downX, float nowX) {
                long duration = AliyunVodPlayerView.this.mAliyunVodPlayer.getDuration();
                long position = AliyunVodPlayerView.this.mAliyunVodPlayer.getCurrentPosition();
                long deltaPosition = 0L;
                if(AliyunVodPlayerView.this.mAliyunVodPlayer.isPlaying()) {
                    deltaPosition = (long)(nowX - downX) * duration / (long)AliyunVodPlayerView.this.getWidth();
                }

                if(AliyunVodPlayerView.this.mGestureDialogManager != null) {
                    AliyunVodPlayerView.this.mGestureDialogManager.showSeekDialog(AliyunVodPlayerView.this, (int)position);
                    AliyunVodPlayerView.this.mGestureDialogManager.updateSeekDialog(duration, position, deltaPosition);
                }

            }

            public void onLeftVerticalDistance(float downY, float nowY) {
                int changePercent = (int)((nowY - downY) * 100.0F / (float)AliyunVodPlayerView.this.getHeight());
                if(AliyunVodPlayerView.this.mGestureDialogManager != null) {
                    AliyunVodPlayerView.this.mGestureDialogManager.showBrightnessDialog(AliyunVodPlayerView.this);
                    AliyunVodPlayerView.this.mGestureDialogManager.updateBrightnessDialog(changePercent);
                }

            }

            public void onRightVerticalDistance(float downY, float nowY) {
                int changePercent = (int)((nowY - downY) * 100.0F / (float)AliyunVodPlayerView.this.getHeight());
                int volume = AliyunVodPlayerView.this.mAliyunVodPlayer.getVolume();
                if(AliyunVodPlayerView.this.mGestureDialogManager != null) {
                    AliyunVodPlayerView.this.mGestureDialogManager.showVolumeDialog(AliyunVodPlayerView.this, volume);
                    int targetVolume = AliyunVodPlayerView.this.mGestureDialogManager.updateVolumeDialog(changePercent);
                    AliyunVodPlayerView.this.mAliyunVodPlayer.setVolume(targetVolume);
                }

            }

            public void onGestureEnd() {
                if(AliyunVodPlayerView.this.mGestureDialogManager != null) {
                    AliyunVodPlayerView.this.mGestureDialogManager.dismissBrightnessDialog();
                    AliyunVodPlayerView.this.mGestureDialogManager.dismissVolumeDialog();
                    int seekPosition = AliyunVodPlayerView.this.mGestureDialogManager.dismissSeekDialog();
                    if((long)seekPosition >= AliyunVodPlayerView.this.mAliyunVodPlayer.getDuration()) {
                        seekPosition = (int)(AliyunVodPlayerView.this.mAliyunVodPlayer.getDuration() - 1000L);
                    }

                    if(seekPosition >= 0) {
                        AliyunVodPlayerView.this.mAliyunVodPlayer.seekTo(seekPosition);
                    }
                }

            }

            public void onSingleTap() {
                if(AliyunVodPlayerView.this.mControlView.getVisibility() != VISIBLE) {
                    AliyunVodPlayerView.this.mControlView.show();
                } else {
                    AliyunVodPlayerView.this.mControlView.hide(HideType.Normal);
                }

            }

            public void onDoubleTap() {
                AliyunVodPlayerView.this.switchPlayerState();
            }
        });
    }

    private void initSurfaceView() {
        this.mSurfaceView = new SurfaceView(this.getContext().getApplicationContext());
        this.addSubView(this.mSurfaceView);
        SurfaceHolder holder = this.mSurfaceView.getHolder();
        holder.addCallback(new Callback() {
            public void surfaceCreated(SurfaceHolder surfaceHolder) {
                VcPlayerLog.d(AliyunVodPlayerView.TAG, " surfaceCreated = surfaceHolder = " + surfaceHolder);
                AliyunVodPlayerView.this.mAliyunVodPlayer.setDisplay(surfaceHolder);
            }

            public void surfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) {
                VcPlayerLog.d(AliyunVodPlayerView.TAG, " surfaceChanged surfaceHolder = " + surfaceHolder + " ,  width = " + width + " , height = " + height);
                AliyunVodPlayerView.this.mAliyunVodPlayer.surfaceChanged();
            }

            public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
                VcPlayerLog.d(AliyunVodPlayerView.TAG, " surfaceDestroyed = surfaceHolder = " + surfaceHolder);
            }
        });
    }

    private void initAliVcPlayer() {
        this.mAliyunVodPlayer = new AliyunVodPlayer(this.getContext());
        this.mAliyunVodPlayer.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared() {
                if(AliyunVodPlayerView.this.mAliyunVodPlayer != null) {
                    AliyunVodPlayerView.this.mAliyunMediaInfo = AliyunVodPlayerView.this.mAliyunVodPlayer.getMediaInfo();
                    if(AliyunVodPlayerView.this.mAliyunMediaInfo != null) {
                        AliyunVodPlayerView.this.mAliyunMediaInfo.setDuration((int)AliyunVodPlayerView.this.mAliyunVodPlayer.getDuration());
                        AliyunVodPlayerView.this.mControlView.setMediaInfo(AliyunVodPlayerView.this.mAliyunMediaInfo, AliyunVodPlayerView.this.mAliyunVodPlayer.getCurrentQuality());
                        AliyunVodPlayerView.this.mControlView.show();
                        AliyunVodPlayerView.this.mGestureView.show();
                        AliyunVodPlayerView.this.startProgressUpdateTimer();
                        if(AliyunVodPlayerView.this.mOutPreparedListener != null) {
                            AliyunVodPlayerView.this.mOutPreparedListener.onPrepared();
                        }

                    }
                }
            }
        });
        this.mAliyunVodPlayer.setOnErrorListener(new OnErrorListener() {
            public void onError(int errorCode, int errorEvent, String errorMsg) {
                AliyunVodPlayerView.this.stopProgressUpdateTimer();
                AliyunVodPlayerView.this.showErrorDialog(errorCode, errorEvent, errorMsg);
                if(AliyunVodPlayerView.this.mOutErrorListener != null) {
                    AliyunVodPlayerView.this.mOutErrorListener.onError(errorCode, errorEvent, errorMsg);
                }

            }
        });
        this.mAliyunVodPlayer.setOnLoadingListener(new OnLoadingListener() {
            public void onLoadStart() {
                if(AliyunVodPlayerView.this.mTipsView != null) {
                    AliyunVodPlayerView.this.mTipsView.showLoadingDialog();
                }

            }

            public void onLoadEnd() {
                if(AliyunVodPlayerView.this.mTipsView != null) {
                    AliyunVodPlayerView.this.mTipsView.hideLoadingDialog();
                }

            }

            public void onLoadProgress(int percent) {
                if(AliyunVodPlayerView.this.mTipsView != null) {
                    AliyunVodPlayerView.this.mTipsView.updateLoadingPercent(percent);
                }

            }
        });
        this.mAliyunVodPlayer.setOnCompletionListener(new OnCompletionListener() {
            public void onCompletion() {
                AliyunVodPlayerView.this.stopProgressUpdateTimer();
                AliyunVodPlayer aliyunVodPlayer = AliyunVodPlayerView.this.mAliyunVodPlayer;
                aliyunVodPlayer.stop();
                aliyunVodPlayer.release();
                if(AliyunVodPlayerView.this.mSurfaceView != null) {
                    AliyunVodPlayerView.this.mSurfaceView.setVisibility(View.GONE);
                    AliyunVodPlayerView.this.mSurfaceView.setVisibility(View.VISIBLE);
                }

                if(AliyunVodPlayerView.this.mTipsView != null) {
                    AliyunVodPlayerView.this.mGestureView.hide(HideType.End);
                    AliyunVodPlayerView.this.mControlView.hide(HideType.End);
                    AliyunVodPlayerView.this.mTipsView.showReplayDialog();
                }

                if(AliyunVodPlayerView.this.mOutCompletionListener != null) {
                    AliyunVodPlayerView.this.mOutCompletionListener.onCompletion();
                }

            }
        });
        this.mAliyunVodPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
            public void onBufferingUpdate(int percent) {
                AliyunVodPlayerView.this.mCurrentBufferPercentage = percent;
            }
        });
        this.mAliyunVodPlayer.setOnInfoListener(new OnInfoListener() {
            public void onInfo(int arg0, int arg1) {
                if(AliyunVodPlayerView.this.mOutInfoListener != null) {
                    AliyunVodPlayerView.this.mOutInfoListener.onInfo(arg0, arg1);
                }

            }
        });
        this.mAliyunVodPlayer.setOnChangeQualityListener(new OnChangeQualityListener() {
            public void onChangeQualitySuccess(String finalQuality) {
                AliyunVodPlayerView.this.mControlView.updateQuality(finalQuality);
                if(AliyunVodPlayerView.this.mOutChangeQualityListener != null) {
                    AliyunVodPlayerView.this.mOutChangeQualityListener.onChangeQualitySuccess(finalQuality);
                }

            }

            public void onChangeQualityFail(int code, String msg) {
                if(AliyunVodPlayerView.this.mOutChangeQualityListener != null) {
                    AliyunVodPlayerView.this.mOutChangeQualityListener.onChangeQualityFail(code, msg);
                }

            }
        });
        this.mAliyunVodPlayer.setDisplay(this.mSurfaceView.getHolder());
    }

    public int getBufferPercentage() {
        return this.mAliyunVodPlayer != null?this.mCurrentBufferPercentage:0;
    }

    public int getDuration() {
        return this.mAliyunVodPlayer != null && this.mAliyunVodPlayer.isPlaying()?(int)this.mAliyunVodPlayer.getDuration():0;
    }

    public int getCurrentPosition() {
        return this.mAliyunVodPlayer != null && this.mAliyunVodPlayer.isPlaying()?(int)this.mAliyunVodPlayer.getCurrentPosition():0;
    }

    private void showErrorDialog(int errorCode, int errorEvent, String errorMsg) {
        if(this.mAliyunVodPlayer.isPlaying()) {
            this.mAliyunVodPlayer.pause();
        }

        this.mAliyunVodPlayer.stop();
        this.mAliyunVodPlayer.release();
        if(this.mTipsView != null) {
            this.mGestureView.hide(HideType.End);
            this.mControlView.hide(HideType.End);
            this.mCoverView.setVisibility(View.GONE);
            this.mTipsView.showErrorDialog(errorCode, errorEvent, errorMsg);
        }

    }

    private void addSubView(View view) {
        LayoutParams params = new LayoutParams(-1, -1);
        this.addView(view, params);
    }

    public void changeScreenMode(AliyunScreenMode aliyunScreenMode) {
        if(this.mControlView != null) {
            this.mControlView.setScreenMode(aliyunScreenMode);
        }

    }

    public void setOnPreparedListener(OnPreparedListener onPreparedListener) {
        this.mOutPreparedListener = onPreparedListener;
    }

    public void setOnErrorListener(OnErrorListener onErrorListener) {
        this.mOutErrorListener = onErrorListener;
    }

    public void setOnInfoListener(OnInfoListener onInfoListener) {
        this.mOutInfoListener = onInfoListener;
    }

    public void setOnCompletionListener(OnCompletionListener onCompletionListener) {
        this.mOutCompletionListener = onCompletionListener;
    }

    public void setOnChangeQualityListener(OnChangeQualityListener l) {
        this.mOutChangeQualityListener = l;
    }

    /** @deprecated */
    @Deprecated
    public void setDataSource(AliyunDataSource aliyunDataSource) {
        this.mAliyunDataSource = aliyunDataSource;
        this.mAliyunVodPlayer.setDataSource(aliyunDataSource);
        if(this.mControlView != null) {
            this.mControlView.forceQuality(aliyunDataSource.isForceQuality());
        }

        this.mAliyunVodPlayer.prepareAsync();
    }

    public void setAuthInfo(AliyunPlayAuth aliyunPlayAuth) {
        this.mAliyunPlayAuth = aliyunPlayAuth;
        this.mAliyunVodPlayer.setAuthInfo(aliyunPlayAuth);
        if(this.mControlView != null) {
            this.mControlView.forceQuality(aliyunPlayAuth.isForceQuality());
        }

        this.mAliyunVodPlayer.prepareAsync();
    }

    public void setLocalSource(AliyunLocalSource aliyunLocalSource) {
        this.mAliyunLocalSource = aliyunLocalSource;
        this.mAliyunVodPlayer.setLocalSource(aliyunLocalSource);
        if(this.mControlView != null) {
            this.mControlView.forceQuality(true);
        }

        this.mAliyunVodPlayer.prepareAsync();
    }

    public void setCoverUri(String uri) {
        if(this.mCoverView != null && !TextUtils.isEmpty(uri)) {
            this.mCoverView.setVisibility(VISIBLE);
            UrlImageViewHelper.setUrlDrawable(this.mCoverView, uri);
        }

    }

    public void setCoverResource(int resId) {
        if(this.mCoverView != null) {
            this.mCoverView.setVisibility(VISIBLE);
            this.mCoverView.setImageResource(resId);
        }

    }

    private void startProgressUpdateTimer() {
        if(this.progressUpdateTimer != null) {
            this.progressUpdateTimer.removeMessages(VISIBLE);
            this.progressUpdateTimer.sendEmptyMessageDelayed(0, 1000L);
        }

    }

    private void stopProgressUpdateTimer() {
        if(this.progressUpdateTimer != null) {
            this.progressUpdateTimer.removeMessages(0);
        }

    }

    public void onResume() {
        int orientation = this.getResources().getConfiguration().orientation;
        if(orientation == 1) {
            this.changeScreenMode(AliyunScreenMode.Small);
        } else if(orientation == 2) {
            this.changeScreenMode(AliyunScreenMode.Full);
        }

        if(this.mNetWatchdog != null) {
            this.mNetWatchdog.startWatch();
        }

        if(this.mControlView != null) {
            this.mControlView.show();
        }

        this.resumePlayerState();
    }

    public void onStop() {
        if(this.mNetWatchdog != null) {
            this.mNetWatchdog.stopWatch();
        }

        this.savePlayerState();
    }

    private void resumePlayerState() {
        if(this.mPlayerState == PlayerState.Paused) {
            this.mAliyunVodPlayer.pause();
        } else if(this.mPlayerState == PlayerState.Started) {
            this.mAliyunVodPlayer.start();
        }

    }

    private void savePlayerState() {
        this.mPlayerState = this.mAliyunVodPlayer.getPlayerState();
        if(this.mAliyunVodPlayer.isPlaying()) {
            this.mAliyunVodPlayer.pause();
        }

    }

    public AliyunMediaInfo getMediaInfo() {
        return this.mAliyunVodPlayer != null?this.mAliyunVodPlayer.getMediaInfo():null;
    }

    public void onDestroy() {
        if(this.mAliyunVodPlayer != null) {
            this.mAliyunVodPlayer.stop();
            this.mAliyunVodPlayer.release();
        }

        this.stopProgressUpdateTimer();
        this.progressUpdateTimer = null;
    }

    public boolean isPlaying() {
        return this.mAliyunVodPlayer != null?this.mAliyunVodPlayer.isPlaying():false;
    }

    public PlayerState getPlayerState() {
        return this.mAliyunVodPlayer != null?this.mAliyunVodPlayer.getPlayerState():null;
    }

    public void start() {
        if(this.mAliyunVodPlayer != null) {
            PlayerState playerState = this.mAliyunVodPlayer.getPlayerState();
            if(playerState == PlayerState.Paused || playerState == PlayerState.Prepared) {
                this.mCoverView.setVisibility(View.GONE);
                this.mAliyunVodPlayer.start();
                this.mControlView.updatePlayState(PlayState.Playing);
            }
        }
    }

    public void pause() {
        if(this.mAliyunVodPlayer != null) {
            PlayerState playerState = this.mAliyunVodPlayer.getPlayerState();
            if(playerState == PlayerState.Started) {
                this.mAliyunVodPlayer.pause();
                this.mControlView.updatePlayState(PlayState.NotPlaying);
            }

        }
    }

    public void seekTo(int position) {
        if(this.mAliyunVodPlayer != null) {
            this.mAliyunVodPlayer.seekTo(position);
        }
    }

    public void setTitleBarCanShow(boolean show) {
        if(this.mControlView != null) {
            this.mControlView.setTitleBarCanShow(show);
        }

    }

    public void setControlBarCanShow(boolean show) {
        if(this.mControlView != null) {
            this.mControlView.setControlBarCanShow(show);
        }

    }

    public void enableNativeLog() {
        if(this.mAliyunVodPlayer != null) {
            this.mAliyunVodPlayer.enableNativeLog();
        }

    }

    public void disableNativeLog() {
        if(this.mAliyunVodPlayer != null) {
            this.mAliyunVodPlayer.disableNativeLog();
        }

    }

    public void setThreadExecutorService(ExecutorService executorService) {
        if(this.mAliyunVodPlayer != null) {
            this.mAliyunVodPlayer.setThreadExecutorService(executorService);
        }

    }

    public String getSDKVersion() {
        return AliyunVodPlayer.getSDKVersion();
    }

    public interface ReplaySourceCallback {
        void setReplaySource();
    }

    public interface GestureCallBack{
        void singTop();
        void doubleTap();
    }
}
